/**
 * Software License, Version 1.0
 *
 * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
 *
 *
 *Redistribution and use in source and binary forms, with or without
 *modification, are permitted provided that the following conditions are met:
 *
 *1) All redistributions of source code must retain the above copyright notice,
 * the list of authors in the original source code, this list of conditions and
 * the disclaimer listed in this license;
 *2) All redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the disclaimer listed in this license in
 * the documentation and/or other materials provided with the distribution;
 *3) Any documentation included with all redistributions must include the
 * following acknowledgement:
 *
 *"This product includes software developed by the Community Grids Lab. For
 * further information contact the Community Grids Lab at
 * http://communitygrids.iu.edu/."
 *
 * Alternatively, this acknowledgement may appear in the software itself, and
 * wherever such third-party acknowledgments normally appear.
 *
 *4) The name Indiana University or Community Grids Lab or NaradaBrokering,
 * shall not be used to endorse or promote products derived from this software
 * without prior written permission from Indiana University.  For written
 * permission, please contact the Advanced Research and Technology Institute
 * ("ARTI") at 351 West 10th Street, Indianapolis, Indiana 46202.
 *5) Products derived from this software may not be called NaradaBrokering,
 * nor may Indiana University or Community Grids Lab or NaradaBrokering appear
 * in their name, without prior written permission of ARTI.
 *
 *
 * Indiana University provides no reassurances that the source code provided
 * does not infringe the patent or any other intellectual property rights of
 * any other entity.  Indiana University disclaims any liability to any
 * recipient for claims brought by any other entity based on infringement of
 * intellectual property rights or otherwise.
 *
 *LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH NO
 *WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA UNIVERSITY GIVES
 *NO WARRANTIES AND MAKES NO REPRESENTATION THAT SOFTWARE IS FREE OF
 *INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER PROPRIETARY RIGHTS.
 *INDIANA UNIVERSITY MAKES NO WARRANTIES THAT SOFTWARE IS FREE FROM "BUGS",
 *"VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", OR OTHER HARMFUL CODE.
 *LICENSEE ASSUMES THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR
 *ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION
 *GENERATED USING SOFTWARE.
 */
/**
 * Generated on May 5, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cgl.narada.service.storage.db;

import java.sql.Connection;
import java.sql.SQLException;

import cgl.narada.service.ServiceException;

/**
 * <p>Title: DatabaseStatements</p>
 *
 * <p>Description: Statements for Mysql</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * @author Hasan Bulut  - hbulut@indiana.edu
 */
public class DatabaseStatements {
    private Connection connection;
    // update statements
    private java.sql.PreparedStatement updateInventoryLightStatusStmt;

    // insert statements
    private java.sql.PreparedStatement insertIntoEntityStmt;
    private java.sql.PreparedStatement insertIntoEntityInventoryStmt;
    private java.sql.PreparedStatement insertIntoEntityTemplateStmt;
    private java.sql.PreparedStatement insertIntoInventoryFullStmt;

    private java.sql.PreparedStatement insertIntoInventoryLightStmt;

    private java.sql.PreparedStatement insertIntoProfileStmt;
    private java.sql.PreparedStatement insertIntoTemplateStmt;
    private java.sql.PreparedStatement insertIntoTimestampInfoStmt;

    //delete statements
    private java.sql.PreparedStatement deleteFromEntity13Stmt;
    private java.sql.PreparedStatement deleteFromEntityInventory13Stmt;
    private java.sql.PreparedStatement deleteFromEntityInventory25Stmt;
    private java.sql.PreparedStatement deleteFromEntityTemplate15Stmt;
    private java.sql.PreparedStatement deleteFromInventoryFull13Stmt;

    private java.sql.PreparedStatement deleteFromInventoryLight13Stmt;

    private java.sql.PreparedStatement deleteFromProfile15Stmt;
    private java.sql.PreparedStatement deleteFromTemplate13Stmt;
    private java.sql.PreparedStatement deleteFromTimestampInfo13Stmt;

    // update statement
    private java.sql.PreparedStatement updateEntityTemplate16Stmt;
    private java.sql.PreparedStatement updateEntityTemplate26Stmt;
    private java.sql.PreparedStatement updateEntityInventory16Stmt;

    // select statement
    private java.sql.PreparedStatement selectTemplateBytesFromTemplateStmt;
    private java.sql.PreparedStatement selectAllFromEntityStmt;
    private java.sql.PreparedStatement selectMAXSeqNumberFromInventoryFullStmt;

    private java.sql.PreparedStatement
            selectMAXSeqNumberFromInventoryLight1Stmt;

    private java.sql.PreparedStatement
            selectMAXSeqNumberFromEntityInventoryStmt;
    private java.sql.PreparedStatement selectEntityIdFromEntityTemplateStmt;
    private java.sql.PreparedStatement selectEventFromInventoryFullStmt;

    private java.sql.PreparedStatement
            selectMAXSeqNumberFromInventoryLight2Stmt;

    private java.sql.PreparedStatement
            selectProfileTypeSubscriptionFromProfileStmt;
    private java.sql.PreparedStatement
            selectSeqNumberTimestampFromTimestampInfo15Stmt;

    private java.sql.PreparedStatement selectSeqNumberFromInventoryLight15Stmt;

    private java.sql.PreparedStatement
            selectMINSeqNumberTimestampFromTimestampInfoStmt;
    private java.sql.PreparedStatement
            selectMAXSeqNumberTimestampFromTimestampInfoStmt;
    private java.sql.PreparedStatement selectSyncpointFromEntityTemplateStmt;
    private java.sql.PreparedStatement selectCatenationFromEntityTemplateStmt;
    private java.sql.PreparedStatement selectAllFromEntityInventoryStmt;
    private java.sql.PreparedStatement selectTimestampFromTimestampInfoStmt;
    private java.sql.PreparedStatement selectSeqNumberFromTimestampInfoStmt;
    private java.sql.PreparedStatement
            selectSeqNumberTimestampFromTimestampInfo29Stmt;
    private java.sql.PreparedStatement
            selectSeqNumberTimestampFromTimestampInfo39Stmt;

    private java.sql.PreparedStatement selectSeqNumberFromInventoryLight29Stmt;
    private java.sql.PreparedStatement
            selectSeqNumberFromEntityInventoryInventoryLightStmt;

    private java.sql.PreparedStatement timestampInfoCompleteRowStmt;
    private java.sql.PreparedStatement timestampInfoCompleteRowDESCStmt;
    private java.sql.PreparedStatement inventoryLightCompleteRowStmt;
    private java.sql.PreparedStatement inventoryLightCompleteRowDESCStmt;

    private String moduleName = "DatabaseStatements: ";
    private boolean initialized = false;
    private static DatabaseStatements instance = new DatabaseStatements();
    private DataAccessObject storageDao;

    private DatabaseStatements() {
    }

    public static DatabaseStatements getInstance() {
        return instance;
    }

    public void initialize(Connection connection, DataAccessObject storageDao) {
        this.storageDao = storageDao;
        if (initialized) {
            return;
        }
        initialized = true;
        this.connection = connection;
        if (this.connection == null) {
            System.out.println("Database connection is NULL");
            return;
        }
        this.initializeUpdateStatements();
        this.initializeInsertIntoStatements();
        this.initializeDeleteAndUpdateStatements();
        this.initializeSelectStatements();
    }

    private void initializeConnection() {
        try {
            storageDao.initilizeConnection();
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        this.connection = storageDao.getConnection();
    }

    public void initializeUpdateStatements() {
        String updateInventoryLightStatus =
                "UPDATE InventoryLight SET status=?";
        try {
            updateInventoryLightStatusStmt = connection.prepareStatement(
                    updateInventoryLightStatus);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void initializeInsertIntoStatements() {
        String insertIntoEntity = "INSERT INTO Entity VALUES ( ? )";
        String insertIntoEntityInventory =
                "INSERT INTO EntityInventory VALUES( ? ,?)";
        String insertIntoEntityTemplate =
                "INSERT INTO EntityTemplate VALUES ( ?, ? , 0, 0)";
        String insertIntoInventoryFull =
                "INSERT INTO InventoryFull VALUES ( ? , ? , ? , ? ,?)";

        String insertIntoInventoryLight =
                "INSERT INTO InventoryLight VALUES ( ? , ? , ?, ?, ?)"; // modified

        String insertIntoProfile =
                "INSERT INTO Profile VALUES ( ? , ? , ? , ? ,? )";
        String insertIntoTemplate = "INSERT INTO Template VALUES ( ? , ? , ?)";
        String insertIntoTimestampInfo =
                "INSERT INTO TimestampInfo VALUES ( ? , ? ,? )";

        try {
            insertIntoEntityStmt = connection.prepareStatement(insertIntoEntity);
            insertIntoEntityInventoryStmt = connection
                                            .prepareStatement(
                    insertIntoEntityInventory);
            insertIntoEntityTemplateStmt = connection
                                           .prepareStatement(
                    insertIntoEntityTemplate);
            insertIntoInventoryFullStmt = connection
                                          .prepareStatement(
                                                  insertIntoInventoryFull);
            insertIntoInventoryLightStmt = connection
                                           .prepareStatement(
                    insertIntoInventoryLight);
            insertIntoProfileStmt = connection.prepareStatement(
                    insertIntoProfile);
            insertIntoTemplateStmt = connection.prepareStatement(
                    insertIntoTemplate);
            insertIntoTimestampInfoStmt = connection
                                          .prepareStatement(
                                                  insertIntoTimestampInfo);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void initializeDeleteAndUpdateStatements() {
        // delete from Entity where entityId = "+ entityId + ";
        String deleteFromEntity13 = "DELETE FROM Entity WHERE entityId = ?";
        // delete from EntityInventory where sequenceNumber = "+ snEntityInventory + ";
        String deleteFromEntityInventory13 =
                "DELETE FROM EntityInventory WHERE sequenceNumber = ?";
        // delete from EntityInventory where sequenceNumber = "+ sequenceNumber + " and entityid = " + entityId + ";
        String deleteFromEntityInventory25 =
                "DELETE FROM EntityInventory WHERE sequenceNumber = ? AND entityId = ?";
        // delete from EntityTemplate where entityId = "+ entityId + " And " + " templateId = " + templateId + ";
        String deleteFromEntityTemplate15 =
                "DELETE FROM EntityTemplate WHERE entityId = ? AND templateId = ?";
        // delete from InventoryFull where sequenceNumber = "+ snInventory + ";
        // delete from InventoryFull where sequenceNumber =" + maxFull + ";
        String deleteFromInventoryFull13 =
                "DELETE FROM InventoryFull WHERE sequenceNumber = ?";
        // delete from InventoryLight where sequenceNumber = "+ snInventory + ";
        // delete from InventoryLight where sequenceNumber =" + maxLight + ";

        String deleteFromInventoryLight13 =
                "DELETE FROM InventoryLight WHERE sequenceNumber = ?";

        // delete from Profile where templateID = "+ templateId + " And " + " profileId=" + profile.getProfileId() + ";
        String deleteFromProfile15 =
                "DELETE FROM Profile WHERE templateId = ? AND profileId = ?";
        // delete from Template where templateID = "+ templateId + ";
        String deleteFromTemplate13 =
                "DELETE FROM Template WHERE templateId = ?";
        // delete from TimestampInfo where sequenceNumber = "+ sequenceNumber + ";
        String deleteFromTimestampInfo13 =
                "DELETE FROM TimestampInfo WHERE sequenceNumber = ?";

        // update EntityTemplate set syncpoint = "+ syncpoint + " where templateId = "+ templateId+ " and entityId= "+ entityId + ";
        String updateEntityTemplate16 =
                "UPDATE EntityTemplate SET syncpoint = ? WHERE templateId = ? AND entityId = ?";
        // update EntityTemplate set catenation = "+ catenation+ " where templateId = "+ templateId+ " and entityId= "+ entityId + ";
        String updateEntityTemplate26 =
                "UPDATE EntityTemplate SET catenation = ? WHERE templateId = ? AND entityId = ?";
        // update EntityInventory set entityId = 0 where sequenceNumber = "+ sequenceNumber + " and entityid = " + entityId + ";
        String updateEntityInventory16 = "UPDATE EntityInventory SET entityId = ? WHERE sequenceNumber = ? AND entityId = ?";

        try {
            deleteFromEntity13Stmt = connection.prepareStatement(
                    deleteFromEntity13);
            deleteFromEntityInventory13Stmt = connection
                                              .prepareStatement(
                    deleteFromEntityInventory13);
            deleteFromEntityInventory25Stmt = connection
                                              .prepareStatement(
                    deleteFromEntityInventory25);
            deleteFromEntityTemplate15Stmt = connection
                                             .prepareStatement(
                    deleteFromEntityTemplate15);
            deleteFromInventoryFull13Stmt = connection
                                            .prepareStatement(
                    deleteFromInventoryFull13);
            deleteFromInventoryLight13Stmt = connection
                                             .prepareStatement(
                    deleteFromInventoryLight13);
            deleteFromProfile15Stmt = connection
                                      .prepareStatement(deleteFromProfile15);
            deleteFromTemplate13Stmt = connection
                                       .prepareStatement(deleteFromTemplate13);
            deleteFromTimestampInfo13Stmt = connection
                                            .prepareStatement(
                    deleteFromTimestampInfo13);

            updateEntityTemplate16Stmt = connection
                                         .prepareStatement(
                                                 updateEntityTemplate16);
            updateEntityTemplate26Stmt = connection
                                         .prepareStatement(
                                                 updateEntityTemplate26);
            updateEntityInventory16Stmt = connection
                                          .prepareStatement(
                                                  updateEntityInventory16);

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void initializeSelectStatements() {
        // select templateBytes from Template;
        String selectTemplateBytesFromTemplate =
                "SELECT templateBytes FROM Template";
        // select * from Entity;
        String selectAllFromEntity = "SELECT * FROM Entity";
        // select MAX(sequenceNumber) from InventoryFull
        String selectMAXSeqNumberFromInventoryFull =
                "SELECT MAX(SequenceNumber) "
                + "FROM InventoryFull";

        // select MAX(sequenceNumber) from InventoryLight
        String selectMAXSeqNumberFromInventoryLight1 =
                "SELECT MAX(SequenceNumber) "
                + "FROM InventoryLight";

        // select MAX(sequenceNumber) from EntityInventory
        String selectMAXSeqNumberFromEntityInventory =
                "SELECT MAX(SequenceNumber) "
                + "FROM EntityInventory";

        // select entityID from EntityTemplate where templateId = "+ templateId + ";
        String selectEntityIdFromEntityTemplate = "SELECT entityId "
                                                  +
                                                  "FROM EntityTemplate WHERE templateId = ?";
        // select event from InventoryFull where sequenceNumber = "+ sequenceNumber + ";
        String selectEventFromInventoryFull =
                "SELECT event FROM InventoryFull "
                + "WHERE sequenceNumber = ?";

        // select MAX(sequenceNumber) from InventoryLight where templateId = "+ templateId + ";
        String selectMAXSeqNumberFromInventoryLight2 =
                "SELECT MAX(SequenceNumber) "
                + "FROM InventoryLight WHERE templateId = ?";

        // select profileType, subscription from Profile where templateId = "+ templateId + ";
        String selectProfileTypeSubscriptionFromProfile =
                "SELECT profileType, "
                + "subscription FROM Profile WHERE templateId = ?";
        // select sequenceNumberStr , timestampStr  from timestampTableStr where templateIdStr  =  templateId ;
        String selectSeqNumberTimestampFromTimestampInfo15 =
                "SELECT sequenceNumber, "
                + "timestamp FROM TimestampInfo WHERE templateId = ?";

        // select SequenceNumber from InventoryLight" + " where "+ "templateId = "+ templateId + " group by SequenceNumber " + ";
        String selectSeqNumberFromInventoryLight15 = "SELECT SequenceNumber "
                +
                "FROM InventoryLight WHERE templateId = ? GROUP BY SequenceNumber";
        // select MIN("sequenceNumberStr "), MIN(" timestampStr") from " + timestampTableStr + " where " + templateIdStr + " = " + templateId
        String selectMINSeqNumberTimestampFromTimestampInfo = "SELECT "
                + "MIN(SequenceNumber), MIN(Timestamp) "
                + "FROM TimestampInfo WHERE templateId = ?";
        // select MAX(sequenceNumberStr), MAX(timestampStr) from " + timestampTableStr + " where " + templateIdStr + " = " + templateId
        String selectMAXSeqNumberTimestampFromTimestampInfo = "SELECT "
                + "MAX(SequenceNumber), MAX(Timestamp) "
                + "FROM TimestampInfo WHERE templateId = ?";

        // select syncpoint from EntityTemplate where templateId = "+ templateId + " And " + " entityId = " + entityId + ";
        String selectSyncpointFromEntityTemplate = "SELECT syncpoint "
                + "FROM EntityTemplate WHERE templateId = ? AND entityId = ?";
        // select catenation from EntityTemplate where templateId = "+ templateId + " And " + " entityId = " + entityId + ";
        String selectCatenationFromEntityTemplate = "SELECT catenation "
                + "FROM EntityTemplate WHERE templateId = ? AND entityId = ?";
        // select * from EntityInventory where sequenceNumber = "+ sequenceNumber + " and entityid = 0
        String selectAllFromEntityInventory = "SELECT * FROM EntityInventory "
                                              +
                                              "WHERE sequenceNumber = ? AND entityId = 0";
        // select +timestampStr + " from " + timestampTableStr + " where " + templateIdStr + " = "
        // + templateId + " and " sequenceNumberStr + " = " + sequenceNumber + ";
        String selectTimestampFromTimestampInfo = "SELECT timestamp "
                                                  +
                                                  "FROM TimestampInfo WHERE templateId = ? AND sequenceNumber = ?";

        //		select sequenceNumberStr from timestampTableStr  where
        //		templateIdStr  =  templateId and timestampStr  >=
        //		startingTimestamp and timestampStr <= endingTimestamp ;
        String selectSeqNumberFromTimestampInfo = "SELECT SequenceNumber "
                                                  + "FROM TimestampInfo "
                                                  +
                                                  "WHERE templateId = ?  AND timestamp >= ? AND timestamp <= ?";

        //		select "sequenceNumberStr + ", " timestampStr + " from " + this.timestampTableStr + " where "
        //		+ templateIdStr + " = " + templateId + " and " + this.timestampStr + " >= " startingTimestamp
        //		+ " and " timestampStr + " <= " + endingTimestamp + ";
        String selectSeqNumberTimestampFromTimestampInfo29 =
                "SELECT SequenceNumber, "
                + "Timestamp FROM TimestampInfo "
                + "WHERE templateId = ? AND timestamp >= ? AND timestamp <= ?";

        //		select " sequenceNumberStr + ", " timestampStr + " from " + this.timestampTableStr + " where "
        //		" templateIdStr + " = " + templateId  + " and sequenceNumberStr + " >= " + startingSequenceNumber
        //		+ " and " + timestampStr + " <= " + endingTimestamp + ";"
        String selectSeqNumberTimestampFromTimestampInfo39 =
                "SELECT SequenceNumber, "
                + "Timestamp FROM TimestampInfo "
                +
                "WHERE templateId = ? AND sequenceNumber >= ? AND timestamp <= ?";

        //		select SequenceNumber from InventoryLight"
        //		+ " where SequenceNumber>="+ startingAt
        //		+ " and "+ " SequenceNumber <= "+ endingAt
        //		+ " and "+ "templateId = " + templateId
        //		+ " group by SequenceNumber " + ";

        String selectSeqNumberFromInventoryLight29 = "SELECT SequenceNumber "
                + "FROM InventoryLight "
                +
                "WHERE SequenceNumber >=? AND SequenceNumber <= ? AND templateId = ? "
                + "GROUP BY SequenceNumber";

        //		String selectEntry12 = "SELECT ? FROM ?, ? WHERE ? >= ? AND ? <= ? AND ? = ? AND ? = ? GROUP BY ?";
        String selectSeqNumberFromEntityInventoryInventoryLight = "SELECT "
                +
                "EntityInventory.SequenceNumber FROM EntityInventory, InventoryLight "
                + "WHERE EntityInventory.SequenceNumber >= ? AND "
                +
                "EntityInventory.SequenceNumber <= ? AND EntityInventory.entityId = ? "
                + "AND InventoryLight.templateId = ? "
                + "GROUP BY EntityInventory.SequenceNumber";

        String timestampInfoCompleteRow =
                "SELECT sequenceNumber, timestamp, templateId FROM TimestampInfo "
                + "WHERE templateId = ? LIMIT 100";

        String timestampInfoCompleteRowDESC =
                "SELECT sequenceNumber, timestamp, templateId FROM TimestampInfo "
                + "WHERE templateId = ? ORDER BY sequenceNumber DESC LIMIT 100";

        String inventoryLightCompleteRow =
                "SELECT sequenceNumber, previousSequenceNumber, templateId FROM InventoryLight "
                + "WHERE templateId = ? LIMIT 100";

        String inventoryLightCompleteRowDESC =
                "SELECT sequenceNumber, previousSequenceNumber, templateId FROM InventoryLight "
                + "WHERE templateId = ? ORDER BY sequenceNumber DESC LIMIT 100";

        try {
            selectTemplateBytesFromTemplateStmt = connection
                                                  .prepareStatement(
                    selectTemplateBytesFromTemplate);
            selectAllFromEntityStmt = connection
                                      .prepareStatement(selectAllFromEntity);
            selectMAXSeqNumberFromInventoryFullStmt = connection
                    .prepareStatement(selectMAXSeqNumberFromInventoryFull);
            selectMAXSeqNumberFromInventoryLight1Stmt = connection
                    .prepareStatement(selectMAXSeqNumberFromInventoryLight1);
            selectMAXSeqNumberFromEntityInventoryStmt = connection
                    .prepareStatement(selectMAXSeqNumberFromEntityInventory);
            selectEntityIdFromEntityTemplateStmt = connection
                    .prepareStatement(selectEntityIdFromEntityTemplate);
            selectEventFromInventoryFullStmt = connection
                                               .prepareStatement(
                    selectEventFromInventoryFull);
            selectMAXSeqNumberFromInventoryLight2Stmt = connection
                    .prepareStatement(selectMAXSeqNumberFromInventoryLight2);
            selectProfileTypeSubscriptionFromProfileStmt = connection
                    .prepareStatement(selectProfileTypeSubscriptionFromProfile);
            selectSeqNumberTimestampFromTimestampInfo15Stmt = connection
                    .prepareStatement(
                            selectSeqNumberTimestampFromTimestampInfo15);
            selectSeqNumberFromInventoryLight15Stmt = connection
                    .prepareStatement(selectSeqNumberFromInventoryLight15);
            selectMINSeqNumberTimestampFromTimestampInfoStmt = connection
                    .prepareStatement(
                            selectMINSeqNumberTimestampFromTimestampInfo);
            selectMAXSeqNumberTimestampFromTimestampInfoStmt = connection
                    .prepareStatement(
                            selectMAXSeqNumberTimestampFromTimestampInfo);
            selectSyncpointFromEntityTemplateStmt = connection
                    .prepareStatement(selectSyncpointFromEntityTemplate);
            selectCatenationFromEntityTemplateStmt = connection
                    .prepareStatement(selectCatenationFromEntityTemplate);
            selectAllFromEntityInventoryStmt = connection
                                               .prepareStatement(
                    selectAllFromEntityInventory);
            selectTimestampFromTimestampInfoStmt = connection
                    .prepareStatement(selectTimestampFromTimestampInfo);
            selectSeqNumberFromTimestampInfoStmt = connection
                    .prepareStatement(selectSeqNumberFromTimestampInfo);
            selectSeqNumberTimestampFromTimestampInfo29Stmt = connection
                    .prepareStatement(
                            selectSeqNumberTimestampFromTimestampInfo29);
            selectSeqNumberTimestampFromTimestampInfo39Stmt = connection
                    .prepareStatement(
                            selectSeqNumberTimestampFromTimestampInfo39);
            selectSeqNumberFromInventoryLight29Stmt = connection
                    .prepareStatement(selectSeqNumberFromInventoryLight29);
            selectSeqNumberFromEntityInventoryInventoryLightStmt = connection
                    .prepareStatement(
                            selectSeqNumberFromEntityInventoryInventoryLight);
            timestampInfoCompleteRowStmt = connection
                                           .prepareStatement(
                    timestampInfoCompleteRow);
            timestampInfoCompleteRowDESCStmt = connection
                                               .prepareStatement(
                    timestampInfoCompleteRowDESC);
            inventoryLightCompleteRowStmt = connection
                                            .prepareStatement(
                    inventoryLightCompleteRow);
            inventoryLightCompleteRowDESCStmt = connection
                                                .prepareStatement(
                    inventoryLightCompleteRowDESC);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void executeUpdateInventoryLightStatusStmt(int status) throws
            ServiceException {
        try {
            updateInventoryLightStatusStmt.setInt(1, status);
            updateInventoryLightStatusStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    public void executeInsertIntoEntityStmt(String entityId) throws
            ServiceException {
        try {
            insertIntoEntityStmt.setString(1, entityId);
            insertIntoEntityStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    public void executeInsertIntoEntityInventoryStmt(String sequenceNumber,
            String destAddr) throws ServiceException {
        try {
            insertIntoEntityInventoryStmt.setString(1, sequenceNumber);
            insertIntoEntityInventoryStmt.setString(2, destAddr);
            insertIntoEntityInventoryStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    public void executeInsertIntoEntityTemplateStmt(String templateId,
            String entityId) throws ServiceException {
        try {
            insertIntoEntityTemplateStmt.setString(1, templateId);
            insertIntoEntityTemplateStmt.setString(2, entityId);
            insertIntoEntityTemplateStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    //	"+ sequenceNumber + "," + previousSequenceNumber + "," + eventID+ ", ? ," + templateId + ");
    public void executeInsertIntoInventoryFullStmt(String sequenceNumber,
            String previousSequenceNumber, String eventID, byte[] eventString,
            String templateId) throws ServiceException {
        try {
            insertIntoInventoryFullStmt.setString(1, sequenceNumber);
            insertIntoInventoryFullStmt.setString(2, previousSequenceNumber);
            insertIntoInventoryFullStmt.setString(3, eventID);
            insertIntoInventoryFullStmt.setBytes(4, eventString);
            insertIntoInventoryFullStmt.setString(5, templateId);
            insertIntoInventoryFullStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    //	insert into InventoryLight values ("+ sequenceNumber + "," + previousSequenceNumber
    //+ "," + templateId+ ");
    public void executeInsertIntoInventoryLightStmt(String sequenceNumber,
            String previousSequenceNumber, String templateId, String catenation,
            String status) throws
            ServiceException {
        try {
            insertIntoInventoryLightStmt.setString(1, sequenceNumber);
            insertIntoInventoryLightStmt.setString(2, previousSequenceNumber);
            insertIntoInventoryLightStmt.setString(3, templateId);
            insertIntoInventoryLightStmt.setString(4, catenation);
            insertIntoInventoryLightStmt.setString(5, status);
            insertIntoInventoryLightStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // insert into Profile values ('" + profileId+ "'," + profileType + " , ?," + templateId + "," + destinationAddress+ ");

    public void executeInsertIntoProfileStmt(String profileId,
                                             String profileType,
                                             byte[] subscription,
                                             String templateId,
                                             String destinationAddress) throws
            ServiceException {
        try {
            insertIntoProfileStmt.setString(1, profileId);
            insertIntoProfileStmt.setString(2, profileType);
            insertIntoProfileStmt.setBytes(3, subscription);
            insertIntoProfileStmt.setString(4, templateId);
            insertIntoProfileStmt.setString(5, destinationAddress);
            insertIntoProfileStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // insert into Template values (" + templateID + "," + templateType + ",?);
    public void executeInsertIntoTemplateStmt(String templateID,
                                              String templateType,
                                              byte[] templateInfo) throws
            ServiceException {
        try {
            insertIntoTemplateStmt.setString(1, templateID);
            insertIntoTemplateStmt.setString(2, templateType);
            insertIntoTemplateStmt.setBytes(3, templateInfo);
            insertIntoTemplateStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // insert into TimestampInfo values (" + sequenceNumber + "," + timestamp + "," + templateId+ ");
    public void executeInsertIntoTimestampInfoStmt(String sequenceNumber,
            String timestamp, String templateId) throws ServiceException {
        try {
            insertIntoTimestampInfoStmt.setString(1, sequenceNumber);
            insertIntoTimestampInfoStmt.setString(2, timestamp);
            insertIntoTimestampInfoStmt.setString(3, templateId);
            insertIntoTimestampInfoStmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    public void executeDeleteFromEntity13Stmt(String entityId) throws
            ServiceException {
        try {
            deleteFromEntity13Stmt.setString(1, entityId);
            deleteFromEntity13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    //deleteFromEntityInventory13Stmt
    public void executeDeleteFromEntityInventory13Stmt(String sequenceNumber) throws
            ServiceException {
        try {
            deleteFromEntityInventory13Stmt.setString(1, sequenceNumber);
            deleteFromEntityInventory13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    //deleteFromEntityInventory25 = "DELETE FROM EntityInventory WHERE sequenceNumber = ? AND entityId = ?";
    public void executeDeleteFromEntityInventory25Stmt(String sequenceNumber,
            String entityId) throws ServiceException {
        try {
            deleteFromEntityInventory25Stmt.setString(1, sequenceNumber);
            deleteFromEntityInventory25Stmt.setString(2, entityId);
            deleteFromEntityInventory25Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // deleteFromEEntityTemplate15 = "DELETE FROM EntityTemplate WHERE entityId = ? AND templateId = ?";
    public void executeDeleteFromEntityTemplate15Stmt(String entityId,
            String templateId) throws ServiceException {
        try {
            deleteFromEntityTemplate15Stmt.setString(1, entityId);
            deleteFromEntityTemplate15Stmt.setString(2, templateId);
            deleteFromEntityTemplate15Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // deleteFromInventoryFull13 = "DELETE FROM InventoryFull WHERE sequenceNumber = ?";
    public void executeDeleteFromInventoryFull13Stmt(String sequenceNumber) throws
            ServiceException {
        try {
            deleteFromInventoryFull13Stmt.setString(1, sequenceNumber);
            deleteFromInventoryFull13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // deleteFromInventoryLight13 = "DELETE FROM InventoryLight WHERE sequenceNumber = ?";
    public void executeDeleteFromInventoryLight13(String sequenceNumber) throws
            ServiceException {
        try {
            deleteFromInventoryLight13Stmt.setString(1, sequenceNumber);
            deleteFromInventoryLight13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // deleteFromProfile15 = "DELETE FROM Profile WHERE templateId = ? AND profileId = ?";
    public void executeDeleteFromProfile15Stmt(String templateId,
                                               String profileId) throws
            ServiceException {
        try {
            deleteFromProfile15Stmt.setString(1, templateId);
            deleteFromProfile15Stmt.setString(2, profileId);
            deleteFromProfile15Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    // deleteFromTemplate13 = "DELETE FROM Template WHERE templateId = ?";
    public void executeDeleteFromTemplate13Stmt(String templateId) throws
            ServiceException {
        try {
            deleteFromTemplate13Stmt.setString(1, templateId);
            deleteFromTemplate13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    //	deleteFromTimestampInfo13 = "DELETE FROM TimestampInfo WHERE sequenceNumber = ?";
    public void executeDeleteFromTimestampInfo13Stmt(String sequenceNumber) throws
            ServiceException {
        try {
            deleteFromTimestampInfo13Stmt.setString(1, sequenceNumber);
            deleteFromTimestampInfo13Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // updateEntityTemplate16 = "UPDATE EntityTemplate SET syncpoint = ? WHERE templateId = ? AND entityId = ?";
    public void executeUpdateEntityTemplate16Stmt(String syncpoint,
                                                  String templateId,
                                                  String entityId) throws
            ServiceException {
        try {
            updateEntityTemplate16Stmt.setString(1, syncpoint);
            updateEntityTemplate16Stmt.setString(2, templateId);
            updateEntityTemplate16Stmt.setString(3, entityId);
            updateEntityTemplate16Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // updateEntityTemplate26 = "UPDATE EntityTemplate SET catenation = ? WHERE templateId = ? AND entityId = ?";
    public void executeUpdateEntityTemplate26Stmt(String catenation,
                                                  String templateId,
                                                  String entityId) throws
            ServiceException {
        try {
            updateEntityTemplate26Stmt.setString(1, catenation);
            updateEntityTemplate26Stmt.setString(2, templateId);
            updateEntityTemplate26Stmt.setString(3, entityId);
            updateEntityTemplate26Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // updateEntityInventory16 = "UPDATE EntityInventory SET entityId = ? WHERE sequenceNumber = ? AND entityId = ?";
    public void executeUpdateEntityInventory16Stmt(String entityId1,
            String sequenceNumber, String entityId2) throws ServiceException {
        try {
            updateEntityInventory16Stmt.setString(1, entityId1);
            updateEntityInventory16Stmt.setString(2, sequenceNumber);
            updateEntityInventory16Stmt.setString(3, entityId2);
            updateEntityInventory16Stmt.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
    }

    // selectTemplateBytesFromTemplate = "SELECT templateBytes FROM Template";
    public java.sql.ResultSet executeSelectTemplateBytesFromTemplateStmt() throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            resultSet = selectTemplateBytesFromTemplateStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    // selectAllFromEntity = "SELECT * FROM Entity";
    public java.sql.ResultSet executeSelectAllFromEntity9Stmt() throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            resultSet = selectAllFromEntityStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    // selectMAXSeqNumberFromInventoryFull = "SELECT MAX(SequenceNumber) FROM InventoryFull";
    public java.sql.ResultSet executeSelectMAXSeqNumberFromInventoryFullStmt() throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            resultSet = selectMAXSeqNumberFromInventoryFullStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    // selectMAXSeqNumberFromInventoryLight1 = "SELECT MAX(SequenceNumber) FROM InventoryLight";
    public java.sql.ResultSet executeSelectMAXSeqNumberFromInventoryLight1Stmt() throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            resultSet = selectMAXSeqNumberFromInventoryLight1Stmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    // selectMAXSeqNumberFromEntityInventory = "SELECT MAX(SequenceNumber) FROM EntityInventory";
    public java.sql.ResultSet executeSelectMAXSeqNumberFromEntityInventoryStmt() throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            resultSet = selectMAXSeqNumberFromEntityInventoryStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    // selectEntityIdFromEntityTemplate = "SELECT entityId FROM EntityTemplate WHERE templateId = ?";
    public java.sql.ResultSet executeSelectEntityIdFromEntityTemplateStmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectEntityIdFromEntityTemplateStmt.setString(1, templateId);
            resultSet = selectEntityIdFromEntityTemplateStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectEventFromInventoryFull = "SELECT event FROM InventoryFull WHERE sequenceNumber = ?";
    public java.sql.ResultSet executeSelectEventFromInventoryFullStmt(
            String sequenceNumber) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectEventFromInventoryFullStmt.setString(1, sequenceNumber);
            resultSet = selectEventFromInventoryFullStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectMAXSeqNumberFromInventoryLight2 = "SELECT MAX(SequenceNumber) " +
    //	"FROM InventoryLight WHERE templateId = ?";
    public java.sql.ResultSet executeSelectMAXSeqNumberFromInventoryLight2Stmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectMAXSeqNumberFromInventoryLight2Stmt.setString(1, templateId);
            resultSet = selectMAXSeqNumberFromInventoryLight2Stmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectProfileTypeSubscriptionFromProfile = "SELECT profileType, " +
    //	"subscription FROM Profile WHERE templateId = ?";
    public java.sql.ResultSet
            executeSelectProfileTypeSubscriptionFromProfileStmt(
                    String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectProfileTypeSubscriptionFromProfileStmt.setString(1,
                    templateId);
            resultSet = selectProfileTypeSubscriptionFromProfileStmt.
                        executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberTimestampFromTimestampInfo15 = "SELECT sequenceNumber, " +
    //	"timestamp FROM TimestampInfo WHERE templateId = ?";
    public java.sql.ResultSet
            executeSelectSeqNumberTimestampFromTimestampInfo15Stmt(
                    String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberTimestampFromTimestampInfo15Stmt.setString(1,
                    templateId);
            resultSet = selectSeqNumberTimestampFromTimestampInfo15Stmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberFromInventoryLight15 = "SELECT SequenceNumber " +
    //	"FROM InventoryLight WHERE templateId = ? GROUP BY SequenceNumber";
    public java.sql.ResultSet executeSelectSeqNumberFromInventoryLight15Stmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberFromInventoryLight15Stmt.setString(1, templateId);
            resultSet = selectSeqNumberFromInventoryLight15Stmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectMINSeqNumberTimestampFromTimestampInfo = "SELECT " +
    //	"MIN(SequenceNumber), MIN(Timestamp) " +
    //	"FROM TimestampInfo WHERE templateId = ?";
    public java.sql.ResultSet
            executeSelectMINSeqNumberTimestampFromTimestampInfoStmt(
                    String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectMINSeqNumberTimestampFromTimestampInfoStmt.setString(1,
                    templateId);
            resultSet = selectMINSeqNumberTimestampFromTimestampInfoStmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectMAXSeqNumberTimestampFromTimestampInfo = "SELECT " +
    //	"MAX(SequenceNumber), MAX(Timestamp) "
    //+ "FROM TimestampInfo WHERE templateId = ?";
    public java.sql.ResultSet
            executeSelectMAXSeqNumberTimestampFromTimestampInfoStmt(
                    String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectMAXSeqNumberTimestampFromTimestampInfoStmt.setString(1,
                    templateId);
            resultSet = selectMAXSeqNumberTimestampFromTimestampInfoStmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSyncpointFromEntityTemplate = "SELECT syncpoint " +
    //	"FROM EntityTemplate WHERE templateId = ? AND entityId = ?";
    public java.sql.ResultSet executeSelectSyncpointFromEntityTemplateStmt(
            String templateId, String entityId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSyncpointFromEntityTemplateStmt.setString(1, templateId);
            selectSyncpointFromEntityTemplateStmt.setString(2, entityId);
            resultSet = selectSyncpointFromEntityTemplateStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectCatenationFromEntityTemplate = "SELECT catenation " +
    //	"FROM EntityTemplate WHERE templateId = ? AND entityId = ?";
    public java.sql.ResultSet executeSelectCatenationFromEntityTemplateStmt(
            String templateId, String entityId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectCatenationFromEntityTemplateStmt.setString(1, templateId);
            selectCatenationFromEntityTemplateStmt.setString(2, entityId);
            resultSet = selectCatenationFromEntityTemplateStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectAllFromEntityTemplate = "SELECT * FROM EntityInventory " +
    //	"WHERE sequenceNumber = ? AND entityId = 0";
    public java.sql.ResultSet executeSelectAllFromEntityInventoryStmt(
            String sequenceNumber) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectAllFromEntityInventoryStmt.setString(1, sequenceNumber);
            resultSet = selectAllFromEntityInventoryStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectTimestampFromTimestampInfo = "SELECT timestamp " +
    //	"FROM TimestampInfo WHERE templateId = ? AND sequenceNumber = ?";
    public java.sql.ResultSet executeSelectTimestampFromTimestampInfoStmt(
            String templateId, String sequenceNumber) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectTimestampFromTimestampInfoStmt.setString(1, templateId);
            selectTimestampFromTimestampInfoStmt.setString(2, sequenceNumber);
            resultSet = selectTimestampFromTimestampInfoStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberFromTimestampInfo = "SELECT SequenceNumber " +
    //	"FROM TimestampInfo "
    //+ "WHERE templateId = ?  AND timestamp >= ? AND timestamp <= ?";
    public java.sql.ResultSet executeSelectSeqNumberFromTimestampInfoStmt(
            String templateId, String timestamp1, String timestamp2) throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberFromTimestampInfoStmt.setString(1, templateId);
            selectSeqNumberFromTimestampInfoStmt.setString(2, timestamp1);
            selectSeqNumberFromTimestampInfoStmt.setString(3, timestamp2);
            resultSet = selectSeqNumberFromTimestampInfoStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberTimestampFromTimestampInfo29 = "SELECT SequenceNumber, " +
    //	"Timestamp FROM TimestampInfo "
    //+ "WHERE templateId = ? AND timestamp >= ? AND timestamp <= ?";
    public java.sql.ResultSet
            executeSelectSeqNumberTimestampFromTimestampInfo29Stmt(
                    String templateId, String timestamp1, String timestamp2) throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberTimestampFromTimestampInfo29Stmt.setString(1,
                    templateId);
            selectSeqNumberTimestampFromTimestampInfo29Stmt.setString(2,
                    timestamp1);
            selectSeqNumberTimestampFromTimestampInfo29Stmt.setString(3,
                    timestamp2);
            resultSet = selectSeqNumberTimestampFromTimestampInfo29Stmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberTimestampFromTimestampInfo39 = "SELECT SequenceNumber, "
    //		+ "Timestamp FROM TimestampInfo "
    //		+ "WHERE templateId = ? AND sequenceNumber >= ? AND timestamp <= ?";
    public java.sql.ResultSet
            executeSelectSeqNumberTimestampFromTimestampInfo39Stmt(
                    String templateId, String sequenceNumber, String timestamp) throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberTimestampFromTimestampInfo39Stmt.setString(1,
                    templateId);
            selectSeqNumberTimestampFromTimestampInfo39Stmt.setString(2,
                    sequenceNumber);
            selectSeqNumberTimestampFromTimestampInfo39Stmt.setString(3,
                    timestamp);
            resultSet = selectSeqNumberTimestampFromTimestampInfo39Stmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberFromInventoryLight29 = "SELECT SequenceNumber " +
    //	"FROM InventoryLight "
    //+ "WHERE SequenceNumber >=? AND SequenceNumber <= ? AND templateId = ? "
    //+ "GROUP BY SequenceNumber";
    public java.sql.ResultSet executeSelectSeqNumberFromInventoryLight29Stmt(
            String seqNumber1, String seqNumber2, String templateId) throws
            ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberFromInventoryLight29Stmt.setString(1, seqNumber1);
            selectSeqNumberFromInventoryLight29Stmt.setString(2, seqNumber2);
            selectSeqNumberFromInventoryLight29Stmt.setString(3, templateId);
            resultSet = selectSeqNumberFromInventoryLight29Stmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    //	selectSeqNumberFromEntityInventoryInventoryLight = "SELECT " +
    //	"EntityInventory.SequenceNumber FROM EntityInventory, InventoryLight " +
    //	"WHERE EntityInventory.SequenceNumber >= ? AND " +
    //	"EntityInventory.SequenceNumber <= ? AND EntityInventory.entityId = ? " +
    //	"AND InventoryLight.templateId = ? " +
    //	"GROUP BY EntityInventory.SequenceNumber;";

    public java.sql.ResultSet
            executeSelectSeqNumberFromEntityInventoryInventoryLightStmt(
                    String seqNumber1, String seqNumber2, String entityId,
                    String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        try {
            selectSeqNumberFromEntityInventoryInventoryLightStmt.setString(1,
                    seqNumber1);
            selectSeqNumberFromEntityInventoryInventoryLightStmt.setString(2,
                    seqNumber2);
            selectSeqNumberFromEntityInventoryInventoryLightStmt.setString(3,
                    entityId);
            selectSeqNumberFromEntityInventoryInventoryLightStmt.setString(4,
                    templateId);
            resultSet = selectSeqNumberFromEntityInventoryInventoryLightStmt
                        .executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    public java.sql.ResultSet executeTimestampInfoCompleteRowStmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        //		timestampInfoCompleteRowStmt
        try {
            timestampInfoCompleteRowStmt.setString(1, templateId);
            resultSet = timestampInfoCompleteRowStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    public java.sql.ResultSet executeTimestampInfoCompleteRowDESCStmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        //		timestampInfoCompleteRowDESCStmt
        try {
            timestampInfoCompleteRowDESCStmt.setString(1, templateId);
            resultSet = timestampInfoCompleteRowDESCStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    public java.sql.ResultSet executeInventoryLightCompleteRowStmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        //		inventoryLightCompleteRowStmt
        try {
            inventoryLightCompleteRowStmt.setString(1, templateId);
            resultSet = inventoryLightCompleteRowStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    public java.sql.ResultSet executeInventoryLightCompleteRowDESCStmt(
            String templateId) throws ServiceException {
        java.sql.ResultSet resultSet = null;
        //		inventoryLightCompleteRowDESCStmt
        try {
            inventoryLightCompleteRowDESCStmt.setString(1, templateId);
            resultSet = inventoryLightCompleteRowDESCStmt.executeQuery();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ServiceException(moduleName + e.toString());
        }
        return resultSet;
    }

    public static void main(String[] args) {
    }

}
